﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;

/// <summary>
/// Summary description for BasePage
/// </summary>
public class BasePage : System.Web.UI.Page
{
    public BasePage()
    {
        //
        // TODO: Add constructor logic here
        //
    }
    protected static void SetSessionNULL()
    {
        HttpContext.Current.Session["QUICKlINKSTYPE"] = null;
        HttpContext.Current.Session["CATEGORYLINKSTYPE"] = null;
        HttpContext.Current.Session["GOVTJOBS"] = null;
        HttpContext.Current.Session["NEWSPAPERJOBS"] = null;
        HttpContext.Current.Session["JOBTYPE"] = null;
        HttpContext.Current.Session["LOCATIONWISE"] = null;
    }
    [WebMethod]
    public static void SetSearchStrToSession(string what, string where)
    {
        SetSessionNULL();
        HttpContext.Current.Session["what"] = what;
        HttpContext.Current.Session["where"] = where;
    }

    [WebMethod(EnableSession = true)]
    public static void SetQuickLinksToSession(string quickLinkType)
    {
        SetSessionNULL();
        HttpContext.Current.Session["QUICKlINKSTYPE"] = quickLinkType;
    }

    [WebMethod(EnableSession = true)]
    public static void setAllJobsLinksToSession(string categoryID)
    {
        SetSessionNULL();
        HttpContext.Current.Session["CATEGORYLINKSTYPE"] = categoryID;
    }

    [WebMethod(EnableSession = true)]
    public static void setGovtJobsLinksToSession(string categoryID)
    {
        SetSessionNULL();
        HttpContext.Current.Session["CATEGORYLINKSTYPE"] = categoryID;
        HttpContext.Current.Session["GOVTJOBS"] = true;
    }

    [WebMethod(EnableSession = true)]
    public static void setNewspaperJobsLinksToSession(string categoryID)
    {
        SetSessionNULL();
        HttpContext.Current.Session["CATEGORYLINKSTYPE"] = categoryID;
        HttpContext.Current.Session["NEWSPAPERJOBS"] = true;
    }

    [WebMethod(EnableSession = true)]
    public static void SetJobTypeToSession(string jobType)
    {
        SetSessionNULL();
        HttpContext.Current.Session["JOBTYPE"] = jobType;
    }

    [WebMethod(EnableSession = true)]
    public static void SetLocationToSession(string location, string locName)
    {
        SetSessionNULL();
        HttpContext.Current.Session["LOCATIONWISE"] = location;
        HttpContext.Current.Session["LOCATIONWISENAME"] = locName;
    }

    [WebMethod]
    public static bool RedirectJobSeeker()
    {
        if (HttpContext.Current.Session["user"] != null && HttpContext.Current.Session["user"].Equals(General.Users.JobSeeker.ToString()))
        {
            return true;
        }
        return false;
    }

    protected void ReloadUserInfoSession()
    {
        if (HttpContext.Current.User.Identity.IsAuthenticated)
        {
            if (Session["userInfo"] == null)
            {
                Session["userInfo"] = System.Web.Security.Membership.GetUser((HttpContext.Current.User.Identity).Name);
            }
        }
    }
}